/**
 *  Document   : RoomType
 *  Created on : 17 juil. 2008, 10:21:39
 *  Author     : Rivo
 */

package gla.centralhotel.model;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;


@Entity
@Table(name = "room_type")
@NamedQueries({@NamedQuery(name = "RoomType.findById", query = "SELECT r FROM RoomType r WHERE r.id = :id"),
@NamedQuery(name = "RoomType.findByType", query = "SELECT r FROM RoomType r WHERE r.type = :type")})
public class RoomType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "type", nullable = false)
    private String type;
//    @OneToMany(cascade = CascadeType.ALL, mappedBy = "refRoomType")
//    private Collection<Room> roomCollection;
    /**
     * Champ calculé lor du listage des type de chambre d'un hotel
     */
    @Transient
    private Integer count;

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public RoomType() {
    }

    public RoomType(Integer id) {
        this.id = id;
    }

    public RoomType(Integer id, String type) {
        this.id = id;
        this.type = type;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

//    public Collection<Room> getRoomCollection() {
//        return roomCollection;
//    }
//
//    public void setRoomCollection(Collection<Room> roomCollection) {
//        this.roomCollection = roomCollection;
//    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RoomType)) {
            return false;
        }
        RoomType other = (RoomType) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "gla.centralhotel.model.RoomType[id=" + id + "]";
    }

}
